package com.example.back.mapper;

import com.example.back.entity.ShouCang;
import com.example.back.util.StringUtil;

/**
 * 获取查询语句
 */
public class ShouCangMapperProvider {
    public String getSelectShouCangSql(ShouCang shouCang) {
        StringBuilder sql = new StringBuilder("select id,userId,postId,time from collection where 1=1 ");
        if(shouCang.getUserId() != null){
            sql.append(" and userId like #{userId} ");
        }
        if(shouCang.getPostId() != null){
            sql.append(" and postId like #{postId} ");
        }
        if(StringUtil.isNotEmpty(shouCang.getTime())){
            sql.append(" and time like concat('%',#{time},'%') ");
        }
        return sql.toString();
    }
}
